package Railroad.Components;

import Railroad.Track;
import java.awt.Color;

public abstract class TrackNode extends TrackItem {
    private boolean busy;
    private Track currentTrack;
    
    TrackNode(int id) {
        super(id);
        currentTrack = null;
    }

    // Vráti aktuálnu hodnotu obsadenia daného úseku stanice.
    public boolean getBusy() {
        return busy;
    }    
    
    // Nastaví obsadenie prvku.
    public void setBusy(boolean busy) {
        this.busy = busy;
    }
    
    public Track getCurrentTrack() {
        return currentTrack;
    }
    
    public void setCurrentTrack(Track currentTrack) {
        this.currentTrack = currentTrack;
    }
    
    public Color getColor() {
        if (getBusy()) {
            return Color.RED;
        }
        if(currentTrack!=null)
        {
            return currentTrack.getColor();
        }
        
        return defaultColor;
    }
    
    public boolean isOnTrack() {
        return currentTrack != null;
    }
}